
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath=request.getScheme()+"://"+
                    request.getServerName()+":"+request.getServerPort()+
                    request.getContextPath()+"/";
%>
<html>
<head>
    <title>浏览学生</title>
    <base href="<%=basePath%>"/>
    <script src="webjars/jquery/3.5.1/jquery.min.js"> </script>
    <script type="text/javascript">
       $(function(){
           loadStudentData();
           $("#btnLoader").click(function(){
               loadStudentData();
           })
       })
        function  loadStudentData() {
            $.ajax({
                url:"student/selectStudent.do",
                type:"get",
                dataType:"json",
                success:function (data) {
                    //清楚旧的数据
                    $("#info").html("");
                    $.each(data,function (i,n) {
                        $("#info").append("<tr>")
                            .append("<td>"+n.id+"</td>")
                            .append("<td>"+n.name+"</td>")
                            .append("<td>"+n.age+"</td>")
                            .append("</tr>")
                    })
                }
            })
        }
    </script>
</head>
<body>
   <div align="center">
       <table>
           <thead>
              <tr>
                  <td>学号</td>
                  <td>姓名</td>
                  <td>年龄</td>
              </tr>
           </thead>
           <tbody id="info">

           </tbody>
       </table>
       <input type="button" id="btnLoader" value="查询数据"/>
   </div>
</body>
</html>
